<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>忘记密码</title>
    <link rel="stylesheet" href="layui\css\layui.css">
    <script type="text/javascript" src="script/jquery-3.3.1.min.js"></script>
</head>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>忘记密码</legend>
</fieldset>

<body>

    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-hide">
                <input type="text" id="userid" name="userid" lay-verify="required" autocomplete="off"
                    class="layui-input" hidden>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名</label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="username" lay-verify="required" autocomplete="off"
                    class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">验证问题</label>
            <div class="layui-input-inline">
                <input type="text" id="vquestion" name="vquestion" lay-verify="required" autocomplete="off"
                    class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">问题答案</label>
            <div class="layui-input-inline">
                <input type="text" id="vanswer" name="vanswer" lay-verify="required" placeholder="请输入所选问题的答案"
                    autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="sbmt">确认</button>
            </div>
        </div>
    </form>

    <script src="layui\layui.all.js"></script>
    <script>
        $(function () {
            $.post("/getcuruser", data,
                function (data) {
                    $("#userid").val(data.userid);
                    $("#username").val(data.username);
                    $("#vquestion").val(data.secq)
                },
                "json"
            );
        })

        layui.use(['form', 'layedit', 'laydate'], function () {
            
            var form = layui.form,
                layer = layui.layer,
                layedit = layui.layedit,
                laydate = layui.laydate;

            //监听提交
            form.on('submit(sbmt)', function (data) {

                $.post("/factoryplat/xxxxxxxxxxxxxxxxx", //修改ajax post的url与属性名称
                    "userid=" + data.field.userid +
                    "&seca=" + data.field.vanswer ,
                    function (data) {
                        if (data == "true") {
                            window.location.href='fgtpassword3.html';
                        } else {
                            layer.msg("验证答案错误", {
                                time: 300
                            });
                        }
                    }, "text");

                return false;
            });


        });
    </script>
</body>

</html>